
#include "aos/hal/flash.h"
#include <aos/kernel.h>

/* Logic partition on flash devices */
hal_logic_partition_t hal_partitions[HAL_PARTITION_MAX];

void board_flash_partition_init(void)
{
    hal_partitions[HAL_PARTITION_BOOTLOADER].partition_owner            = HAL_FLASH_QSPI;
    hal_partitions[HAL_PARTITION_BOOTLOADER].partition_description      = "Bootloader";
    hal_partitions[HAL_PARTITION_BOOTLOADER].partition_start_addr       = 0x60000000;
    hal_partitions[HAL_PARTITION_BOOTLOADER].partition_length           = 0x00030000;        /* 192k bytes */
    hal_partitions[HAL_PARTITION_BOOTLOADER].partition_options          = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;

    hal_partitions[HAL_PARTITION_APPLICATION].partition_owner            = HAL_FLASH_QSPI;
    hal_partitions[HAL_PARTITION_APPLICATION].partition_description      = "Application";
    hal_partitions[HAL_PARTITION_APPLICATION].partition_start_addr       = 0x60040000;
    hal_partitions[HAL_PARTITION_APPLICATION].partition_length           = 0x00180000;       /* 1.5M bytes */
    hal_partitions[HAL_PARTITION_APPLICATION].partition_options          = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;

    hal_partitions[HAL_PARTITION_PARAMETER_1].partition_owner            = HAL_FLASH_QSPI;
    hal_partitions[HAL_PARTITION_PARAMETER_1].partition_description      = "PARAMETER1";     /* used for OTA param */
    hal_partitions[HAL_PARTITION_PARAMETER_1].partition_start_addr       = 0x603FC000;
    hal_partitions[HAL_PARTITION_PARAMETER_1].partition_length           = 0x00001000;       /* 4k bytes */
    hal_partitions[HAL_PARTITION_PARAMETER_1].partition_options          = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;

    hal_partitions[HAL_PARTITION_PARAMETER_2].partition_owner            = HAL_FLASH_QSPI;
    hal_partitions[HAL_PARTITION_PARAMETER_2].partition_description      = "PARAMETER2";     /* used for kv */
    hal_partitions[HAL_PARTITION_PARAMETER_2].partition_start_addr       = 0x603E0000;
    hal_partitions[HAL_PARTITION_PARAMETER_2].partition_length           = 0x0001C000;       /* 112k bytes */
    hal_partitions[HAL_PARTITION_PARAMETER_2].partition_options          = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;

    hal_partitions[HAL_PARTITION_OTA_TEMP].partition_owner               = HAL_FLASH_QSPI;
    hal_partitions[HAL_PARTITION_OTA_TEMP].partition_description         = "OTA Storage";   /* used for OTA backup APP */
    hal_partitions[HAL_PARTITION_OTA_TEMP].partition_start_addr          = 0x60200000;
    hal_partitions[HAL_PARTITION_OTA_TEMP].partition_length              = 0x00180000;      /* 1.5M bytes */
    hal_partitions[HAL_PARTITION_OTA_TEMP].partition_options             = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;
    
    hal_partitions[HAL_PARTITION_PARAMETER_3].partition_owner            = HAL_FLASH_QSPI;
    hal_partitions[HAL_PARTITION_PARAMETER_3].partition_description      = "PARAMETER3";    /* used for security */
    hal_partitions[HAL_PARTITION_PARAMETER_3].partition_start_addr       = 0x603FD000;
    hal_partitions[HAL_PARTITION_PARAMETER_3].partition_length           = 0x00001000;      /* 8k bytes */
    hal_partitions[HAL_PARTITION_PARAMETER_3].partition_options          = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;

    hal_partitions[HAL_PARTITION_PARAMETER_4].partition_owner            = HAL_FLASH_QSPI;
    hal_partitions[HAL_PARTITION_PARAMETER_4].partition_description      = "PARAMETER4";   /* used for security */
    hal_partitions[HAL_PARTITION_PARAMETER_4].partition_start_addr       = 0x603FE000;
    hal_partitions[HAL_PARTITION_PARAMETER_4].partition_length           = 0x00002000;     /* 8k bytes */
    hal_partitions[HAL_PARTITION_PARAMETER_4].partition_options          = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;

    return ;

}


